﻿using Admin2024.Domain.IDomainService.System.IUserService;
using Admin2024.Domain.ObjValue;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Admin2024.Application.Contracts.User
{
    public class PasswordService : IPasswordService
    {
        private readonly IPasswordManagementService passwordManagementService;

        public PasswordService (IPasswordManagementService passwordManagementService)
        {
            this.passwordManagementService = passwordManagementService;
        }

        public async Task<DomainResult<string>> ResetPassword(Guid appUserId, string password)
        {
            var user = await passwordManagementService.ResetPassword(appUserId, password);
            if (!user.IsSuccess)
            {
                return DomainResult<string>.Error(user.Message);
            }

            return DomainResult<string>.Success(user.Data);
        }

        public async Task<DomainResult<string>> UpdatePassword(Guid appUserId, string password)
        {
            var user = await passwordManagementService.UpdatePassword(appUserId, password);
            if (!user.IsSuccess)
            {
                return DomainResult<string>.Error(user.Message);
            }

            return DomainResult<string>.Success(user.Data);
        }
    }
}
